﻿using System;

namespace Moonlite.Data.Configuration
{
    /// <summary>
    /// Indicates that a property has a default value and specific options.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
    public sealed class ConfigurationPropertyAttribute : Attribute
    {
        readonly object defaultValue;
        readonly Type targetType;
        readonly string targetSyncPropertyName;

        /// <summary>
        /// Gets the default value.
        /// </summary>
        /// <value>The default value.</value>
        public object DefaultValue
        {
            get { return defaultValue; }
        }

        /// <summary>
        /// Gets the type of the target that the property should sync with.
        /// </summary>
        /// <value>The type of the target that the property should sync with.</value>
        public Type TargetType
        {
            get { return targetType; }
        }

        /// <summary>
        /// Gets the name of the property that this property should sync with.
        /// </summary>
        /// <value>The name of the property that this property should sync with.</value>
        public string TargetSyncPropertyName
        {
            get { return targetSyncPropertyName; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationPropertyAttribute"/> class.
        /// </summary>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="targetSyncPropertyName">Name of the property that this property should sync with.</param>
        public ConfigurationPropertyAttribute(object defaultValue, Type targetType, string targetSyncPropertyName)
        {
            this.defaultValue = defaultValue;
            this.targetType = targetType;
            this.targetSyncPropertyName = targetSyncPropertyName;
        }
    }
}
